<?php
$this->headScript()
    ->appendFile($this->APP_STATIC_SERVER.'/js/jquery.cycle/jquery.cycle.all.min.js');
?>
<style>
    .p_b_bottom{ padding-bottom:3px; }
    .cycle_nav a:hover, a:active{ text-decoration:none; }
    .cycle_nav a{ text-decoration:none; }    
    .w_box{ display: table-row; }    
    .w_box .cell_image{ display:table-cell; vertical-align:middle; height:105px; }
</style>
<!--Box-->
<div class="caption_box icon_title">
    <div style="float:left; width:85%">
        <span><?php echo $this->translator()->widget('widget_product_most_viewed');?></span>
    </div>
    <div style="float:right; width:15%;" class="cycle_nav">
        <div style="text-align:right; padding-right:5px; margin-top:-3px; font-size:20px;">
            <a id="prev2" href="#">«</a>&nbsp;<a id="next2" href="#s">»</a>
        </div>
    </div>
</div>
<div style="clear:both;"></div>
<div id="mostviewed">
    <?php $w_i = 0;foreach($this->products as $product):?>
    <?php    	
        //Category follow product        
        $objCategory = $this->arrPC[$product->product_id];

        //Enterprise follow product        
        $objEnterprise = $this->arrPE[$product->product_id];

        //Param url detail        
        $arrRouteDetail = array(
            'enterprise_id' => $objEnterprise->id,
            'enterprise_name' => Tomato_Utility_String::removeSign($objEnterprise->company_name_en, '-', true),
            'cat' => $objCategory->category_id,
            'slug' => ($objCategory->slug)?$objCategory->slug:Tomato_Utility_String::removeSign($objCategory->category_admin_name, '-', true),
            'product_id' => $product->product_id,
            'pro_slug' => ($product->slug)?$product->slug:Tomato_Utility_String::removeSign($product->product_admin_name, '-', true),
        );
        $p_name = ($product->product_content_name)?$product->product_content_name:$product->product_admin_name;
    ?>
    <?php if($w_i%2 == 0):?><div style="padding-bottom:3px;"><?php endif;?>
    <div class="w_box">
	    <div class="cell_image">
	    	<?php if($product->getImage()):?>
	        <a href="<?php echo $this->url($arrRouteDetail,'shop_product_detail');?>">
	            <img width="100" src="<?php echo $product->getImage();?>" class="item_img" alt="<?php echo $p_name;?>">
	        </a>
	        <?php endif;?>
	    </div>
	    <div style="margin-left:8px;">
	        <div class="subcolumns_oldgecko">
	            <a href="<?php echo $this->url($arrRouteDetail,'shop_product_detail');?>" title="<?php echo $p_name;?>"><span class="title" style="font-size:9px;">            
	            <?php echo strip_tags(Tomato_Helper_Helper::substring($p_name,30));?></span></a>
	        </div>
	        <div class="subcolumns_oldgecko">
	        	<?php echo strip_tags(Tomato_Helper_Helper::substring($product->product_content_description, 120));?>
	        </div>	        
	        <div>
	            <?php echo $this->translator('front_product_price', 'shop');?>:
	            <strong><?php echo $product->product_price;?> <?php echo $product->product_price_currency;?></strong>
	        </div>
	    </div>
	</div>
    <?php $w_i++; if($w_i%2 == 0){echo '</div>';}?>
    <?php endforeach;?>
    <?php if($w_i%2 != 0){echo '</div>';}?>
</div>
<script type="text/javascript">
$(document).ready(function() {
    $('#mostviewed').cycle({
        fx:     'scrollHorz',
        timeout: 4000,
        delay:  1000,
        next:   '#next2',
        prev:   '#prev2'
    });
});
</script>